﻿@if (User.Identity.IsAuthenticated) {
    <h2>Blog Listing for: @User.Identity.Name</h2>
} else {
    <h2>Sample Blog Listing</h2>
}
<div class="table-responsive">
    <table class="table table-condensed table-striped">
        <tr>
            <th>
                @Html.DisplayName("User Name")
            </th>
            <th>
                @Html.DisplayName("Blog Name")
            </th>
            <th>
                @Html.DisplayName("Blog URL")
            </th>
            @if (User.Identity.IsAuthenticated) {
                <th></th>
            }
        </tr>

        @foreach (LynxWebLog.BlogData item in ViewBag.ListBlogData) {
            <tr>
                <td>
                    @Html.DisplayFor(modelItem => item.username)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.blogname)
                </td>
                <td>
                    <a href="@item.url">@item.url</a>
                </td>
                @if (User.Identity.IsAuthenticated) {
    <td>
        @Html.ActionLink("List Posts", "Index", "PostEntry",
                        routeValues: new { Area = "Blogs", controller = "PostEntry", action = "Index", username = User.Identity.Name, blogname = LynxWebLog.CookieFacade.CurrentBlog },
                        htmlAttributes: null)
    </td>
}
            </tr>
        }

    </table>
</div>
@if (!User.Identity.IsAuthenticated) {
    @Html.ActionLink("Refresh Sample Blog List", "Index", "Home", null, new { @class = "btn btn-default btn-primary" })
} else {
    @Html.ActionLink("Add New Post", "Create", "PostEntry",
        routeValues: new { Area = "Blogs", controller = "PostEntry", action = "Create", username = User.Identity.Name, blogname = LynxWebLog.CookieFacade.CurrentBlog },
        htmlAttributes: new { @class = "btn btn-default btn-primary" })
}
